package com.example.myapplication.xiaochengxu;

import com.example.myapplication.shortvideo.utils.GsonUtil;
import com.google.gson.reflect.TypeToken;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: rongfeng
 * @date: 2021/8/27
 * @description
 */
public class maoer {
    public static void main(String[] args) {
        File file = new File("D:\\wrf\\test\\new.txt");
        try {
            String str;
            FileInputStream fileInputStream = new FileInputStream(file);
            InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

            StringBuffer sb = new StringBuffer();
            String text = null;
            while ((text = bufferedReader.readLine()) != null) {
                sb.append(text);
            }
            str = sb.toString();
            List<Bean> bean = GsonUtil.parseList(str, new TypeToken<List<Bean>>() {
            }.getType());

            List<caier.Bean.TrackList> lists = new ArrayList<>();
            for (Bean item : bean) {
                caier.Bean.TrackList bean1 = new caier.Bean.TrackList();
                bean1.customTitle = item.name;
                bean1.duration = item.duration;
                bean1.tabIds = new int[]{13};
                bean1.trackId = item.id;
                lists.add(bean1);
            }

            String json = GsonUtil.toJson(lists);
            System.out.println(json);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    static class Bean implements Serializable {
        int id;
        String name;
        String sound_id;
        String url;
        int duration;
        static class sound implements Serializable {
            sound2 info;
            sound3 sound;

            static class sound2 {
                sound3 sound;
            }

            static class sound3 {
                String soundurl;
                String soundurl_128;
            }
        }
    }
}
